package com.jt.demo1;

import com.jt.demo1.config.SpringConfig;
import com.jt.demo1.proxy.JDKProxy;
import com.jt.demo1.proxy.TimeProxy;
import com.jt.demo1.service.UserService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

public class TestTx {
    public static void main(String[] args) {
        ApplicationContext context =
                new AnnotationConfigApplicationContext(SpringConfig.class);
        //1.获取目标对象 UserServiceImpl实现类对象
        UserService userService = context.getBean(UserService.class);
        //2.获取代理对象 实现了UserService接口
        UserService proxy = (UserService)JDKProxy.getProxy(userService);
        proxy.addUser();

        UserService proxy1 =(UserService) TimeProxy.getProxy(userService);
        proxy1.addUser();


    }
}
